package com.ruoyi.system.service.impl;

import com.ruoyi.common.config.oss.OssProperties;
import com.ruoyi.common.config.oss.OssTemplate;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysDangerCheck;
import com.ruoyi.system.mapper.SysDangerCheckMapper;
import com.ruoyi.system.service.ISysDangerCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDangerCheckServiceImpl implements ISysDangerCheckService {

    @Autowired
    private OssTemplate template;

    @Autowired
    private OssProperties ossProperties;

    @Autowired
    private SysDangerCheckMapper sysDangerCheckMapper;

    @Override
    public void create(SysDangerCheck sysDangerCheck) {

        sysDangerCheck.setCreateUserId(SecurityUtils.getUserId().intValue());
        sysDangerCheck.setCreateUserName(SecurityUtils.getUsername());
        sysDangerCheck.setUploadName(SecurityUtils.getUsername());
        sysDangerCheckMapper.create(sysDangerCheck);
    }

    @Override
    public List<SysDangerCheck> list(SysDangerCheck sysDangerCheck) {
        return sysDangerCheckMapper.list(sysDangerCheck);
    }

    @Override
    public void delete(Integer id) {
        sysDangerCheckMapper.delete(id);
    }

    @Override
    public void update(SysDangerCheck sysDangerCheck) {
        sysDangerCheck.setUploadName(SecurityUtils.getUsername());
        sysDangerCheckMapper.update(sysDangerCheck);
    }

    @Override
    public void deleteFile(Integer id) {
        String username = SecurityUtils.getUsername();
        sysDangerCheckMapper.updateFileColumn(id,username);
    }
}
